package com.lt.suangua.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lt.suangua.R;
import com.lt.suangua.app.AppAdapter;
import com.lt.suangua.http.api.HomeApi;
import com.lt.suangua.http.glide.GlideApp;
import com.lt.suangua.http.glide.GlideRoundImage;
import com.lt.suangua.utils.GlideUtils;

/**
 *  
 * github : 
 * time   : 2018/11/05
 * desc   : 可进行拷贝的副本
 */
public final class ArticleAdapter extends AppAdapter<HomeApi.Article> {

    public ArticleAdapter(Context context) {
        super(context);
    }

    @Override
    public int getItemCount() {
        return getCount();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        TextView rcitem_desc;
        TextView rcitem_reports;
        TextView rcitem_nums;
        ImageView rcitem_photo;

        private ViewHolder() {

            super(R.layout.item_article);
            rcitem_desc = findViewById(R.id.rcitem_desc);
            rcitem_reports = findViewById(R.id.rcitem_reports);
            rcitem_nums = findViewById(R.id.rcitem_nums);
            rcitem_photo = findViewById(R.id.rcitem_photo);
        }

        @Override
        public void onBindView(int position) {
            rcitem_desc.setText(getItem(position).title);
            rcitem_reports.setText(getItem(position).author);
            rcitem_nums.setText(getItem(position).readnum+"阅读");
            GlideUtils.loadCornerImage(getContext(),getItem(position).pic,rcitem_photo,10);

        }
    }
}